<?php
namespace app\adm\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\Auth;

/**
 * 总控制器
 */
class Index extends Controller{
	public function __construct(Request $request){
		parent::__construct();

		//登陆验证
		if(!session('loginName')) $this->redirect(url('sign/login'));

		//权限验证
		// $auth = new Auth();
		// $rule_name = strtolower($request->module().'/'.$request->controller().'/'.$request->action());
		// $result=$auth->check($rule_name, session('uid'));
		// if(!$result){
		// 	if($request->isAJax()){
		// 		$this->error($rule_name.'您没有权限进行操作');
		// 	}else{
		// 		jsBack('您没有权限进行操作');
		// 	}
		// }
	}
	/*
	 * 首页
	*/
    public function index(Request $request){
    	$list = Db::name('auth_nav')->order('order_number is null,order_number,id')->select();
    	$data = rule_tree($list);
		$this->assign('data',$data);
    	return $this->fetch($request->action(),['title'=>'后台首页']);
    }

    /*
	 * 欢迎页
    */
    public function welcome(Request $request){
    	return $this->fetch($request->action(),['title'=>'欢迎登陆']);
    }

}
